package com.xbongbong.pay.platform.wechatpay.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * 查询退款 错误码
 * @author 魏荣杰
 * @date 2021/1/12 10:26
 * @since
 * @version
 */
@Getter
public enum WeChatQueryRefundErrorEnum {
    /**
     *
     */
    SUCCESS("SUCCESS", "成功"),
    SYSTEMERROR("SYSTEMERROR", "接口返回错误"),
    REFUNDNOTEXIST("REFUNDNOTEXIST", "退款订单查询失败"),
    INVALID_TRANSACTIONID("INVALID_TRANSACTIONID", "无效transaction_id"),
    PARAM_ERROR("PARAM_ERROR", "参数错误"),
    APPID_NOT_EXIST("APPID_NOT_EXIST", "APPID不存在"),
    MCHID_NOT_EXIST("MCHID_NOT_EXIST", "MCHID不存在"),
    REQUIRE_POST_METHOD("REQUIRE_POST_METHOD", "请使用post方法"),
    SIGNERROR("SIGNERROR", "签名错误"),
    XML_FORMAT_ERROR("XML_FORMAT_ERROR", "XML格式错误")
    ;

    /**
     * 错误码
     */
    private final String errorCode;
    /**
     * 说明
     */
    private final String msg;

    WeChatQueryRefundErrorEnum(String errorCode, String msg) {
        this.errorCode = errorCode;
        this.msg = msg;
    }

    public static WeChatQueryRefundErrorEnum getByCode(String errorCode) {
        if (Objects.isNull(errorCode) || errorCode.isEmpty()) {
            return null;
        }
        for (WeChatQueryRefundErrorEnum value : values()) {
            if (Objects.equals(value.getErrorCode(), errorCode)) {
                return value;
            }
        }

        return null;
    }
}
